From 81d01bad71eabc246ea06ae1c4240b84afeda86c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 14 Feb 2007 23:23:36 +0000 Subject: [PATCH] avoid divisions by zero, thus making the reference conversions correct. * babl/base/model-rgb.c: (premultiplied_to_non_premultiplied), (rgba_gamma_2_2_premultiplied2rgba): avoid divisions by zero, thus making the reference conversions correct. svn path=/trunk/; revision=216 --- ChangeLog | 6 ++++++ babl/base/model-rgb.c | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 494f41e..ee5aa21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-02-15 Øyvind Kolås + + * babl/base/model-rgb.c: (premultiplied_to_non_premultiplied), + (rgba_gamma_2_2_premultiplied2rgba): avoid divisions by zero, + thus making the reference conversions correct. + 2007-02-11 Øyvind Kolås * NEWS: updated news for many versions. diff --git a/babl/base/model-rgb.c b/babl/base/model-rgb.c index 1b6e7d5..3a9651d 100644 --- a/babl/base/model-rgb.c +++ b/babl/base/model-rgb.c @@ -289,7 +289,7 @@ premultiplied_to_non_premultiplied (int src_bands, } else { - *(double*)dst[band] = 0.001; + *(double*)dst[band] = 0.00; } } *(double*)dst[dst_bands-1] = alpha; @@ -330,9 +330,18 @@ rgba_gamma_2_2_premultiplied2rgba (char *src, while (n--) { double alpha = ((double*) src)[3]; - ((double*)dst)[0] = gamma_2_2_to_linear (((double*) src)[0] / alpha); - ((double*)dst)[1] = gamma_2_2_to_linear (((double*) src)[1] / alpha); - ((double*)dst)[2] = gamma_2_2_to_linear (((double*) src)[2] / alpha); + if (alpha > 0.0001) + { + ((double*)dst)[0] = gamma_2_2_to_linear (((double*) src)[0] / alpha); + ((double*)dst)[1] = gamma_2_2_to_linear (((double*) src)[1] / alpha); + ((double*)dst)[2] = gamma_2_2_to_linear (((double*) src)[2] / alpha); + } + else + { + ((double*)dst)[0] = 0.0; + ((double*)dst)[1] = 0.0; + ((double*)dst)[2] = 0.0; + } ((double*)dst)[3] = alpha; src+=4 * sizeof (double); -- 2.30.2